package org.example.supplychain.service;

import org.example.supplychain.domain.Inventory;
import org.example.supplychain.mapper.InventoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 仓库管理的Service
 */
@Service
public class InventoryService {
    @Autowired
    private InventoryMapper inventoryMapper;

    /**
     * 添加仓库信息
     *
     * @param inventory 仓库实例
     */
    public void addInventory(Inventory inventory) {
        inventoryMapper.addInventory(inventory);
    }

    /**
     * 添加仓库信息
     *
     * @param inventoryName    仓库名
     * @param inventoryPlace   仓库位置
     * @param inventoryManager 仓库管理员
     */
    public void addInventory(String inventoryName, String inventoryPlace, String inventoryManager) {
        Inventory inventory = new Inventory();
        inventory.setInventoryName(inventoryName);
        inventory.setInventoryPlace(inventoryPlace);
        inventory.setInventoryManager(inventoryManager);
        inventoryMapper.addInventory(inventory);
    }

    /**
     * 删除仓库信息
     *
     * @param inventoryName 仓库名
     */
    public void deleteInventoryByInventoryName(String inventoryName) {
        inventoryMapper.deleteInventoryByInventoryName(inventoryName);
    }

    /**
     * 更新仓库信息
     *
     * @param inventory 仓库实例
     */
    public void updateInventoryByInventoryName(Inventory inventory) {
        inventoryMapper.updateInventoryByInventoryName(inventory);
    }

    /**
     * 获取仓库信息
     *
     * @param inventoryName 仓库名
     * @return 仓库实例
     */
    public Inventory getInventoryByInventoryName(String inventoryName) {
        return inventoryMapper.getInventoryByInventoryName(inventoryName);
    }

    /**
     * 获取所有仓库信息
     *
     * @return 所有仓库实例
     */
    public List<Inventory> getAllInventories() {
        return inventoryMapper.getAllInventories();
    }
}
